// maindlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINDLG_H__CCDDE62F_EDDB_4665_B6D3_91CBB5636920__INCLUDED_)
#define AFX_MAINDLG_H__CCDDE62F_EDDB_4665_B6D3_91CBB5636920__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include <aygshell.h>
#include "FCListviewCtrl.h"
#include "Contosrv.h"
#include "FileTools.h"
#include "constdef.h"

#include "Config.h"

class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>, public CDialogResize<CMainDlg>,
		public CMessageFilter, public CIdleHandler
{
public:
	enum { IDD = IDD_MAINDLG };

	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnIdle();

	BEGIN_UPDATE_UI_MAP(CMainDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
		COMMAND_ID_HANDLER(IDOK, OnOK)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)

		COMMAND_ID_HANDLER(IDC_BTN_VCR, OnVCR)
		COMMAND_ID_HANDLER(IDC_BTN_UPDATA, OnUpdataUser)
		COMMAND_ID_HANDLER(IDC_BTN_VIEW, OnViewMedia)
		COMMAND_ID_HANDLER(IDC_BTN_LOGIN, OnLogin)
		

		NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnItemChanged)
		NOTIFY_CODE_HANDLER(NM_RETURN, OnListClick)
		NOTIFY_CODE_HANDLER(NM_DBLCLK, OnListClick)

		CHAIN_MSG_MAP(CDialogResize<CMainDlg>) 
	END_MSG_MAP()

	BEGIN_DLGRESIZE_MAP(CMainDlg) // Flags: DLSZ_SIZE_X or DLSZ_MOVE_X, DLSZ_SIZE_Y  or DLSZ_MOVE_X, DLSZ_REPAINT
// 		DLGRESIZE_CONTROL(IDC_LIST_USER, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(IDC_NAME, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(IDC_BTN_LOGIN, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(IDC_BTN_VCR, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(IDC_BTN_VIEW, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(IDC_BTN_UPDATA, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(ID_APP_ABOUT, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)
// 		DLGRESIZE_CONTROL(IDOK, DLSZ_SIZE_X | DLSZ_SIZE_Y|DLSZ_REPAINT)

		BEGIN_DLGRESIZE_GROUP()
			DLGRESIZE_CONTROL(IDC_LIST_USER,     DLSZ_SIZE_Y | DLSZ_SIZE_Y )
		END_DLGRESIZE_GROUP()

		BEGIN_DLGRESIZE_GROUP() 
			DLGRESIZE_CONTROL(IDC_NAME,     DLSZ_MOVE_X)
			DLGRESIZE_CONTROL(IDC_PSW,     DLSZ_MOVE_X)
			DLGRESIZE_CONTROL(IDC_BTN_LOGIN,     DLSZ_MOVE_X)
		END_DLGRESIZE_GROUP()

		BEGIN_DLGRESIZE_GROUP() 
			DLGRESIZE_CONTROL(IDC_BTN_VCR,     DLSZ_MOVE_X)
			//DLGRESIZE_CONTROL(IDC_BTN_UPDATA,  DLSZ_MOVE_X)
			DLGRESIZE_CONTROL(IDC_BTN_VIEW,    DLSZ_MOVE_X)
			DLGRESIZE_CONTROL(ID_APP_ABOUT,    DLSZ_MOVE_X)
			DLGRESIZE_CONTROL(IDOK,    DLSZ_MOVE_X)
		END_DLGRESIZE_GROUP()
	END_DLGRESIZE_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	LRESULT OnVCR(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnUpdataUser(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnViewMedia(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnLogin(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);


	LRESULT OnItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
	LRESULT OnListClick(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	void CloseDialog(int nVal);

protected:
	int LoadUsers();
	VOID StartCamera(HWND hwndDlg,char* path, char* name, CAMERACAPTURE_MODE mode);

	void ShowMediaList(TCHAR* userName);
private:
	HMENU m_hMenu;
	CFCListViewCtrl   m_idcList;
	CImageList		m_imgList;
	char            m_vcrName[MAX_PATH];

	CContosrv*		m_ContoSrv;

	CSimpleArray<TPath> m_UserArray;

	BOOL m_bLogined;
	
	//TUserInfo m_UserInfo;
	CConfig* m_Config;
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINDLG_H__CCDDE62F_EDDB_4665_B6D3_91CBB5636920__INCLUDED_)
